import {getByschoolName} from '@/api/pvm/school'
var baseUrl='/admin/region/parentId'


var checkSchoolName = (rule, value, callback) => {
  getByschoolName(value).then(response => {
    if (window.boxType === 'edit') callback()
    const result = response.data.data
    let userNamereg=/^\S+$/
    if (result !== null) {
      callback(new Error('学校已经存在'))
    } else {
      if(!userNamereg.test(value)){
        callback(new Error('不允许有空格'))
      }else{
        callback()
      }
    }
  })
};



export const tableOption = {
  "border": true,
  "index": true,
  "indexLabel": "序号",
  "stripe": true,
  "menuAlign": "center",
  "align": "center",
  refreshBtn: true,
  showClomnuBtn: true,
  searchSize: 'mini',
  addBtn: false,
  editBtn: false,
  viewBtn: false,
  delBtn: false,
  "column": [
	  {
      "type": "input",
      "label": "学校编号",
      "prop": "id",
      hide: true,
      addDisplay: false,
      editDisabled: true
    },	  {
      "type": "input",
      "label": "学校名称",
      "prop": "schoolName",
      editDisabled: true,
      search: true,
      rules: [{
        required: true,
        message: '请输入学校名称',
        trigger: 'blur'
      },
        {validator: checkSchoolName, trigger: 'blur'}
      ],
    },	  {
      "type": "input",
      "label": "拼音编码",
      "prop": "pinyinCode",
      addDisplay: false,
      editDisabled: true,
    },	  {

      "label": "省",
      "prop": "provinceCode",
      "type": "select",
      search: true,
      formslot: true,
      slot: true,
      props: {
        label: 'regionName',
        value: 'id'
      },
      // cascaderItem: ['cityCode', 'areaCode'],
      dicUrl:`${baseUrl}/86`,


      rules: [{
        required: true,
        message: '请选择省级地址',
        trigger: 'change'
      }],
    },	  {
      "label": "省名称",
      "prop": "province",
      "type": "select",
      // search: true,
      addDisplay: false,
      editDisplay: false,
    },	  {
      "type": "select",
      "label": "市",
      "prop": "cityCode",
      // search: true,
      formslot: true,
      slot: true,
      // row: true,
      // dicFlag: false,
      // dicUrl: `${baseUrl}/{{provinceCode}}`,
      // props: {
      //   label: 'regionName',
      //   value: 'id'
      // },
      rules: [{
        required: true,
        message: '请选择市级地址',
        trigger: 'change'
      }],
    },	  {
      "type": "input",
      "label": "市名称",
      "prop": "city",
      // search: true,
      addDisplay: false,
      editDisplay: false
    },	  {
      "label": "区",
      "prop": "areaCode",
      "type": "select",
      formslot: true,
      slot: true,
      // search: true,
      // dicFlag: false,
      // dicUrl: `${baseUrl}/{{cityCode}}`,
      // props: {
      //   label: 'regionName',
      //   value: 'id'
      // },

      rules: [{
        required: true,
        message: '请选择区级地址',
        trigger: 'change'
      }],
    },	  {
      "type": "input",
      "label": "区名称",
      "prop": "area",
      // search: true,
      addDisplay: false,
      editDisplay: false
    },	  {
      "type": "input",
      "label": "详细地址",
      "prop": "address"
    },	  {
      "type": "input",
      "label": "全地址",
      "prop": "fullAddress",
      addDisplay: false,
      editDisplay: false
    },	   {
      label: '学校类型',
      prop: 'schoolType',// 0-幼儿园,1-小学,2-初中,3-高中,4-大学,
      search: true,
      type: 'radio',
      slot: true,
      border:true,
      span: 24,
      rules: [{
        required: true,
        message: '请选择状态',
        trigger: 'blur'
      }],
      dicData: [{
        label: '幼儿园',
        value: 0
      }, {
        label: '小学',
        value: 1
      }, {
        label: '初中',
        value: 2
      }, {
        label: '高中',
        value: 3
      }, {
        label: '大学',
        value: 4
      }]
    },    {
      "type": "form",
      "prop": "pvmGrade",
      span: 24,
      formslot: true,
      hide: true,
    },    {
      "type": "input",
      "label": "学校编码",
      "prop": "schoolCode"
    },	  {
      "type": "radio",
      "label": "学校状态",// 1为启用,-1为停用
      "prop": "status",
      slot: true,
      border:true,
      span: 24,
      rules: [{
        required: true,
        message: '请选择状态',
        trigger: 'blur'
      }],
      dicData: [{
        label: '启用',
        value: 1
      }, {
        label: '停用',
        value: -1
      }]
    },	  {
      "type": "input",
      "label": "学校负责人",
      "prop": "leader"
    },	  {
      "type": "input",
      "label": "联系人",
      "prop": "contectName"
    },	  {
      "type": "input",
      "label": "联系方式",
      "prop": "contect"
    },	  {
      "type": "input",
      "label": "删除标记,1为未删除,-1为删除",
      "prop": "delFlag",
      addDisplay: false,
      editDisplay: false,
      hide: true,
    },	  {
      "type": "input",
      "label": "创建时间",
      "prop": "createTime",
      addDisplay: false,
      hide: true,
      editDisabled: true,
    },	  {
      "type": "input",
      "label": "创建人",
      "prop": "createUser",
      addDisplay: false,
      editDisabled: true,
    },	  {
      "type": "input",
      "label": "修改时间",
      "prop": "updateTime",
      hide:true,
      addDisplay: false,
      editDisplay: false
    },	  {
      "type": "input",
      "label": "修改人",
      "prop": "updateUser",
      hide:true,
      addDisplay: false,
      editDisplay: false
    }  ]
}
